﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ZuluTrade.Core
{
    class ZuluProvider
    {
        #region Свойства

        public String Name
        {
            get;
            set;
        }

        public Int32 RowsSelected
        {
            get;
            set;
        }

        /// <summary>
        /// Accumulated Pips
        /// </summary>
        public Double PipsSum
        {
            get;
            set;
        }

        /// <summary>
        /// Общий убыток.
        /// </summary>
        public Double DeadLoss
        {
            get;
            set;
        }

        public Double MinWorstDrawdown
        {
            get; set;
        }

        public Double MinDeadLoss
        {
            get;
            set;
        }

        public Double MaxHighestProfit
        {
            get;
            set;
        }

        /// <summary>
        /// PF = Общая прибыль/|Общие убытки|
        /// </summary>
        public Double ProfitFactor{
            get{
                if (this.DeadLoss == 0)
                    return this.PipsSum;
                else
                    return Math.Round(this.PipsSum/Math.Abs(this.DeadLoss), 4);
            }
        }

        /// <summary>
        /// RAR = ProfitFactor/|MinimalWorstDrawdown|
        /// </summary>
        public Double RAR{
            get{
                return Math.Round(this.PipsSum / Math.Abs(this.MinWorstDrawdown),4);
            }
        }

        /// <summary>
        /// RAR = ProfitFactor/|MinDeadLoss|
        /// </summary>
        public Double RARreal{
            get
            {
                if (this.MinDeadLoss == 0)
                    return this.PipsSum;
                else
                    return Math.Round(this.PipsSum / Math.Abs(this.MinDeadLoss), 4);
            }
        }


        #endregion

        #region Конструктор

        #endregion

        public override string ToString(){
            StringBuilder sb = new StringBuilder();
            sb.Append(String.Format("Name: ({0}); ", this.Name));
            sb.Append(String.Format("Rows selected: {0}; ", this.RowsSelected));
            sb.Append(String.Format("Max highest profit: {0}; ", this.MaxHighestProfit));
            sb.Append(String.Format("Min worst drawdown: {0}; ", this.MinWorstDrawdown));
            sb.Append(String.Format("Pips sum: ({0});", this.PipsSum));
            sb.Append(String.Format("Dead loss: ({0});", this.DeadLoss));
            sb.Append(String.Format("PF: ({0});", this.ProfitFactor));
            sb.Append(String.Format("RAR: ({0});", this.RAR));
            return sb.ToString();
        }
    }
}
